
import os

from PIL import Image


def jpeg2jpg(path_in, path_out):
    img = Image.open(path_in)
    img = img.convert("RGB")
    img.save(path_out, "JPEG", quality=80, optimize=True, progressive=True)


def png2jpg(path_in, path_out):
    img = Image.open(path_in)
    img = img.convert("RGB")
    img.save(path_out, "JPEG", quality=80, optimize=True, progressive=True)


def JPG2jpg(path_in, path_out):
    img = Image.open(path_in)
    img = img.convert("RGB")
    img.save(path_out, "JPEG", quality=80, optimize=True, progressive=True)


def PNG2jpg(path_in, path_out):
    img = Image.open(path_in)
    img = img.convert("RGB")
    img.save(path_out, "JPEG", quality=80, optimize=True, progressive=True)


def jpg2jpg(path_in, path_out):
    img = Image.open(path_in)
    img = img.convert("RGB")
    img.save(path_out, "JPEG", quality=80, optimize=True, progressive=True)


file_path = os.getcwd()+'/python_interview_exercise/jianshu/tool_codes/'
path_in1 = file_path + '1.jpeg'
path_in2 = file_path + '2.jpeg'

path_out1 = file_path + '111.jpg'
path_out2 = file_path + '222.jpg'

jpeg2jpg(path_in1, path_out1)
jpeg2jpg(path_in2, path_out2)
